﻿@using System.Web.UI.WebControls
@{
    ViewBag.Title = ViewBag.EndpointName;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row">
    <div class="col-md-12">
        <p>
            <h2>Retrain Model "@ViewBag.WebServiceName" on Endpoint "@ViewBag.EndpointName"</h2>
        <p>The will produce the retrained module and retraining results.</p>
    </div>
</div>

<div class="row">
    <div class="col-md-4"><h4>Job Status (auto-refreshs every 3 seconds)</h4></div>
    <div class="col-md-4">
        <h4><div data-bind="html: status"></div></h4>
    </div>
    <div class="col-md-4">
        <a class="btn btn-default" data-bind="click: query">Get Status</a>
    </div>
</div>
<div class="row">
    <div class="col-md-6">
        <p><a id="link1" class="btn btn-primary" href=get_retrain_results target="_blank">Download Retrained Evaluation Results</a></p>
    </div>
    <div class="col-md-6">
        <p><a id="link2" class=" btn btn-primary" href="select_scoring">Update Scoring Experiment with new Trained Model</a></p>
    </div>
</div>

<script type="text/javascript">
    var viewModel = {
        status : ko.observable(),
        query:function() {
            viewModel.status("querying...");
            $.getJSON("get_status/@ViewBag.JobId", function(data) {
                viewModel.status(JSON.stringify(data));
                if (data == "Finished") {
                    $('#link1').show();
                    $('#link2').show();
                }
            });
           window.setTimeout(viewModel.query, 3000);
        }
    }
    ko.applyBindings(viewModel);

     $(document).ready(function() {
         $('#link1').hide();
         $('#link2').hide();
        viewModel.query();
        window.setTimeout(viewModel.query, 3000);
     });
</script>
